package com.ygj.signPoint.action;

import static com.base.common.GlobaConstants.ACTION_RESULT_DATA;
import static com.base.common.GlobaConstants.ASYNCHRONOUS;
import static com.base.common.GlobaConstants.CONTENT_TYPE;
import static com.base.common.GlobaConstants.CONTENT_TYPE_JSON;
import static com.base.common.GlobaConstants.JSON;
import static com.base.common.GlobaConstants.ROOT;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.base.common.action.AbstractBaseAction;
import com.base.common.bean.ActionResult;
import com.cjy.common.bean.OpAttributes;
import com.ygj.signPoint.service.SignPointService;

@Action("signPointAction")
@Results({ @Result(name = ASYNCHRONOUS, type = JSON, params = { ROOT,
		ACTION_RESULT_DATA, CONTENT_TYPE, CONTENT_TYPE_JSON }) })
public class SignPointAction extends AbstractBaseAction {

	private static final long serialVersionUID = 1L;

	@Resource
	private SignPointService signPointService;

	private String code; // 签到点编号
	private String uuid; // 设备码
	private int flag;	// 签到设备识别，0， 二维码，1，摇一摇

	@Override
	public String getUuid() {
		return uuid;
	}

	@Override
	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public int getFlag() {
		return flag;
	}

	public void setFlag(int flag) {
		this.flag = flag;
	}

	/**
	 * 根据uuid或者code查询签到点信息
	 * 
	 * @return
	 */
	public String getSignPointBySome() {
		try {
			actionResult = ActionResult.getActionResult(new OpAttributes().add(
					"code", 1).add("result",
					signPointService.getSignPointBySome(uuid, code, flag)));
		} catch (Exception e) {
			actionResult = ActionResult.getActionResult(new OpAttributes().add(
					"code", 0));
		}
		return returnType();
	}
}
